package com.ztf0337.mycurriculumdesign.dao;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import com.ztf0337.mycurriculumdesign.entity.User;

import java.util.List;

@Dao
public interface UserDao {

    @Insert
    long insert(User user);
    @Delete
    void delete(User user);
    @Update
    void update(User user);
    @Query("SELECT * FROM user_table WHERE id = :id")
    User getUserById(Long id);
    @Query("SELECT * FROM user_table WHERE phone = :phone")
    User getUserByPhone(String phone);

    @Query("SELECT * FROM user_table WHERE root IS 0")
    List<User> getAllUser();

    @Query("SELECT * FROM user_table WHERE phone LIKE '%' || :phone || '%' AND root IS 0")
    List<User> searchAllUser(String phone);

}
